package com.web.util;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import com.web.assist.Pic;

public class PicLoad {

	public static List<Pic> picsLoad(String picsPath, String serverPath){
		List<Pic> pics = new ArrayList<Pic>();
		if(picsPath!=null && !"".equals(picsPath.trim())){
			File f = new File(picsPath);
			if(f.isDirectory()){
				File[] filesTmp = f.listFiles();
				
				List<File> files = Arrays.asList(filesTmp);
				Collections.sort(files, new SortByTimeComparator());
				for(File file : files){
					pics.add(new Pic(file.getName(),serverPath+file.getName()));
					System.out.println(serverPath+file.getName());
				}
			}
		}
		
		return pics;
		
	}
}
